<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>消息查看</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->

</head>
<body class="bg_w">
<div class="content-wrap">
    <div class="layui-row">
        <form class="layui-form layui-form-pane" id="from1">
            <input type="hidden" id="dataId" value="" />
            <div class="layui-row layui-col-space10">
                <div class=" layui-col-sm6">
                    <label class="layui-form-label">模板标题</label>
                    <div class="layui-input-block">
                        <input type="text"  id="templateTitle" readonly="readonly" class="layui-input" lay-verify="required" maxlength="100" placeholder="请输入模板标题">
                    </div>
                </div>
                <div class=" layui-col-sm6">
                    <label class="layui-form-label">模板编号</label>
                    <div class="layui-input-block">
                        <input type="text"  id="templatenum" readonly="readonly" class="layui-input" lay-verify="required" maxlength="100" placeholder="请输入模板标题">
                    </div>
                </div>
                <div class="layui-col-sm12 templateContent" id="templateContentForApp" style="display: none">
                    <div class="layui-form-text">
                        <label class="layui-form-label">APP模板内容</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入APP模板内容" readonly="readonly" class="layui-textarea" style="max-height: 200px;"></textarea>
                        </div>
                    </div>
                </div>
            </div>
                <div class="layui-row layui-col-space10 templateContent" id="wxTemplateForPublic" style="display: none">
                    <div class="layui-col-sm6">
                        <label class="layui-form-label" style="width: 150px;">公众号消息模板ID</label>
                        <div class="layui-input-block" style="margin-left: 150px;">
                            <input type="text" class="layui-input wxTemplateId" readonly="readonly" maxlength="100"/>
                        </div>
                    </div>
                    <div class="layui-col-sm6">
                        <label class="layui-form-label" style="width: 150px;">公众号跳转链接</label>
                        <div class="layui-input-block" style="margin-left: 150px;">
                            <input type="text" class="layui-input wxLinkUrl" readonly="readonly" maxlength="200"/>
                        </div>
                    </div>
                    <div class="layui-col-sm12 layui-form-text">
                        <label class="layui-form-label">公众号模板内容</label>
                        <div class="layui-input-block">
                            <textarea readonly="readonly" class="layui-textarea wxcontent" style="max-height: 200px;"></textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 templateContent" id="wxTemplateForApplet" style="display: none">
                    <div class="layui-col-sm6">
                        <label class="layui-form-label" style="width: 150px;">小程序消息模板ID</label>
                        <div class="layui-input-block" style="margin-left: 150px;">
                            <input type="text" class="layui-input wxTemplateId" readonly="readonly" lay-verify="required" maxlength="100" />
                        </div>
                    </div>
                    <div class="layui-col-sm6">
                        <label class="layui-form-label" style="width: 150px;">小程序跳转链接</label>
                        <div class="layui-input-block" style="margin-left: 150px;">
                            <input type="text" class="layui-input wxLinkUrl" readonly="readonly" lay-verify="required" maxlength="200"/>
                        </div>
                    </div>
                    <div class="layui-col-sm12 ">
                        <div class="layui-form-text">
                            <label class="layui-form-label">小程序模板内容</label>
                            <div class="layui-input-block">
                                <textarea readonly="readonly" class="layui-textarea wxcontent"></textarea>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="layui-row layui-col-space15 templateContent" id="templateContentForSms" style="display: none">
                    <div class="layui-col-sm12 layui-form-text">
                        <label class="layui-form-label">短信模板内容</label>
                        <div class="layui-input-block">
                            <textarea readonly="readonly" class="layui-textarea wxcontent" style="max-height: 200px;"></textarea>
                        </div>
                    </div>
                </div>


            <!--<div class="layui-input-block">-->
                <!--<button type="button" id="btnClose" class="layui-btn layui-btn-primary btn-left">关闭</button>-->
            <!--</div>-->


        </form>
    </div>
</div>


</body>

<script>

    var table;

    layui.use(['table','form','laydate','layer'], function() {
        table = layui.table;
        var form = layui.form,
            laydate = layui.laydate,
            layer=layui.layer,
            $ = layui.jquery;

    });
    // $('#btnClose').on("click", function () {
    //     parent.layer.close(parent.layer.getFrameIndex(window.name));
    // });

    var $;
    layui.use(['layer'], function() {
        $ = layui.$;
        var layer=layui.layer;

        var initPage = function(dataId) {
            ax.get({
                url: schoolWebUrl + "/api/message/template/detail",
                data: {dataId:dataId},
                success: function (res) {
                    if (res.code == 0) {
                        var noticeData = res.data;
                        console.log(noticeData);
                         $('#templatenum').val(noticeData.messageTemplate.mtCode);
                         $('#templateTitle').val(noticeData.messageTemplate.mtTitle)
                        if(noticeData.mtContentForApp==''){
                            $('.templateContentForApp').hide();
                        }else {
                             console.log(noticeData.mtContentForApp)
                            $('#templateContentForApp').show();
                             $('#templateContentForApp').find('textarea').val(noticeData.mtContentForApp);
                        }if(noticeData.mtContentForApplet==''){
                             $('#wxTemplateForApplet').hide();
                        }else {
                            $('#wxTemplateForApplet').show();
                            $('#wxTemplateForApplet').find('.wxTemplateId').val(noticeData.mtWxTemplateIdForApplet);
                            $('#wxTemplateForApplet').find('.wxLinkUrl').val(noticeData.mtUrlForApplet);
                            $('#wxTemplateForApplet').find('.wxcontent').val(noticeData.mtContentForApplet);
                        }if(noticeData.mtContentForPublic==''){
                            $('#wxTemplateForPublic').hide();
                        }else {
                            $('#wxTemplateForPublic').show();
                            $('#wxTemplateForPublic').find('.wxTemplateId').val(noticeData.mtWxTemplateIdForPublic);
                            $('#wxTemplateForPublic').find('.wxLinkUrl').val(noticeData.mtUrlForPublic);
                            $('#wxTemplateForPublic').find('.wxcontent').val(noticeData.mtContentForPublic);
                        }if(noticeData.mtContentForSms==''){
                             $('#templateContentForSms').hide();
                        }else{
                             $('#templateContentForSms').show();
                            $('#templateContentForSms').find('.wxcontent').val(noticeData.mtContentForSms);
                        }

                    } else {
                        layer.msg(res.message);
                    }
                }

            });
        };

        var dataId = getQueryString("id");
        initPage(dataId);
    });


</script>
</html>